




use "$data/survey2_clean.dta", clear

loc experiments "z_impact_1 z_impact_2 z_worry_corona_econ z_worry_perecon"
		   
			  
foreach var of varlist lnday5 lnday10 lnday20{
	egen z_`var' = std(`var')
			}
			  
preserve 

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments'  `experiments' {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""

global output_coeff ""
global output_se ""
global output_name""

foreach choice in `experiments' {

/* Statistics */

	

  xi:  reg `choice' z_lnday5 , vce(r)
    sigstar z_lnday5, prec(4)
    estadd loc thisstat4 = "`r(bstar)'": col`colnum'
    estadd loc thisstat5 = "`r(sestar)'": col`colnum'
	
	estadd loc thisstat7 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'  
	estadd loc thisstat8 =  r(N): col`colnum'
	

 xi:  reg `choice' z_lnday10 , vce(r)
	
   sigstar z_lnday10, prec(4)
    estadd loc thisstat12 = "`r(bstar)'": col`colnum'
    estadd loc thisstat13 = "`r(sestar)'": col`colnum'
	
	
		estadd loc thisstat15 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'  
	estadd loc thisstat16 =  r(N): col`colnum'
	
	
	
xi:  reg `choice' z_lnday20 , vce(r)
	
   sigstar z_lnday20, prec(4)
    estadd loc thisstat20 = "`r(bstar)'": col`colnum'
    estadd loc thisstat21 = "`r(sestar)'": col`colnum'
	
	estadd loc thisstat23 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'  
	estadd loc thisstat24 =  r(N): col`colnum'
			
	estadd loc thisstat25 =  " ": col`colnum'
		
	
	
	    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"	
**** With controls ****



 xi:  reg `choice' z_lnday5 $control, vce(r)
    sigstar z_lnday5, prec(4)
    estadd loc thisstat4 = "`r(bstar)'": col`colnum'
    estadd loc thisstat5 = "`r(sestar)'": col`colnum'
	
	estadd loc thisstat7 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'  
	estadd loc thisstat8 =  r(N): col`colnum'

 xi:  reg `choice' z_lnday10 $control , vce(r)
	
   sigstar z_lnday10, prec(4)
    estadd loc thisstat12 = "`r(bstar)'": col`colnum'
    estadd loc thisstat13 = "`r(sestar)'": col`colnum'
	
	
		estadd loc thisstat15 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'  
	estadd loc thisstat16 =  r(N): col`colnum'
	
xi:  reg `choice' z_lnday20 $control, vce(r)
	
   sigstar z_lnday20, prec(4)
    estadd loc thisstat20 = "`r(bstar)'": col`colnum'
    estadd loc thisstat21 = "`r(sestar)'": col`colnum'
	
	estadd loc thisstat23 = string(`e(r2)', "%9.2f"): col`colnum'
	qui sum `choice'  
	estadd loc thisstat24 =  r(N): col`colnum'
			
	estadd loc thisstat25 =  "X": col`colnum'
		
		
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"



	} 
	

loc rowlabels " " " "{\bf Panel A }" " " "Log(estimate day 5)- z-score" " "  " " "\midrule R$^2$" "Number of Observations " "\midrule" "{\bf Panel B}" " " "Log(estimate day 10)- z-score" " " " " "\midrule R$^2$" "Number of Observations " "\midrule" "{\bf Panel C}" " " "Log(estimate day 20)- z-score" " " " ""\midrule R$^2$" "Number of Observations " "\midrule Controls" "
loc rowstats ""

forval i = 1/25 {
    loc rowstats "`rowstats' thisstat`i'"
}


	



esttab * using "$tables/correlations_expgrowth_combined.tex", replace cells(none) booktabs nonotes compress alignment(c) nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels')) ///
   mtitle("World" "World"  "US" "US" "US Economy" "US Economy" "Pers. Economic Sit." "Pers. Economic Sit." ) ///
   mgroups("Predicted impact on (standardized)" "Worry about (standardized)" ,  pattern(1 0  0 0  1 0   ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))

    
   
   
